<?php

require_once( "../application.php" );
require_once( "Chart.class.php" );

$app	=	new Application();

$app->IsAuthenticationRequired(TRUE);



$chart	=	new	Chart();


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb" lang="en-gb" dir="ltr">
<head>
	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
	<meta name="robots" content="index, follow" />
	<meta name="keywords" content="brunom4ciel" />
	<meta name="description" content="Semantic web" />
	<meta name="generator" content="brunom4ciel" />
	<title>Bruno Maciel</title>
  
  	<link rel="stylesheet" href="css/generic.css" type="text/css" />

<style>

body {
  font: 10px sans-serif;
}

.arc path {
  stroke: #fff;
}

</style>

</head>
<body class="contentpane">
	
	<script src="http://d3js.org/d3.v3.min.js"></script>


<a href="../index.php">Home</a>	
<a href="<?php echo $_SERVER['PHP_SELF'] ;?>"><h1>linguagens de Programação</h1> </a>
	<h1>Bar Chart</h1>
	
<script src="http://d3js.org/d3.v3.min.js"></script>
<script>

var width = 960,
    height = 500,
    radius = Math.min(width, height) / 2;

var color = d3.scale.ordinal()
    .range(["#98abc5", "#8a89a6", "#7b6888", "#6b486b", "#a05d56", "#d0743c", "#ff8c00"]);

var arc = d3.svg.arc()
    .outerRadius(radius - 10)
    .innerRadius(0);

var pie = d3.layout.pie()
    .sort(null)
    .value(function(d) { return d.population; });

var svg = d3.select("body").append("svg")
    .attr("width", width)
    .attr("height", height)
  .append("g")
    .attr("transform", "translate(" + width / 2 + "," + height / 2 + ")");

d3.csv("http://cin.ufpe.br/~bifm/projeto/survey/chart/chart.php?action=ajax&chart=codigolivrefechado", function(error, data) {

  data.forEach(function(d) {
    d.population = +d.population;
  });

  var g = svg.selectAll(".arc")
      .data(pie(data))
    .enter().append("g")
      .attr("class", "arc");

  g.append("path")
      .attr("d", arc)
      .style("fill", function(d) { return color(d.data.age); });

  g.append("text")
      .attr("transform", function(d) { return "translate(" + arc.centroid(d) + ")"; })
      .attr("dy", ".35em")
      .style("text-anchor", "middle")
      .text(function(d) { return d.data.age; });

});

</script>

</body>
</html>